package com.partner.match.model.enums;

import cn.hutool.core.util.ObjectUtil;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author: jzz
 * @CreateTime: 2025-01-26
 * @Description: 队伍状态枚举类
 */

public enum TeamStateEnum {
    PUBLIC("公开",0),
    PRIVATE("私有",1),
    ENCRYPT("加密",2);

    private final String text;
    private final Integer value;

    TeamStateEnum(String text, Integer value) {
        this.text = text;
        this.value = value;
    }

    public String getText() {
        return text;
    }

    public Integer getValue() {
        return value;
    }

    /**
     * 获取值列表
     * @return
     */
    public static List<Integer> getValueList(){
        return Arrays.stream(values()).map(item->item.value).collect(Collectors.toList());
    }

    /**
     * 根据value获取枚举
     * @param value
     * @return
     */
    public static TeamStateEnum getEnumByVale(Integer value){
        if(ObjectUtil.isEmpty(value)){
            return null;
        }
        for (TeamStateEnum anEnum : TeamStateEnum.values()) {
            if(anEnum.value.equals(value)){
                return anEnum;
            }
        }
        return null;
    }
}
